<template>
  <div class="top">
    <button v-for="i in routes" @click="open(i,'p')">{{i.meta.desc}}</button>
  </div>
  <div class="left">
    <button v-for="x in silder" @click="open(x,'c')">{{x.meta.desc}}</button>
  </div>
  <div class="right">
    <router-view/>
  </div>

</template>

<script setup lang="ts">
import { useRouter } from "vue-router"
const router = useRouter()

const routes = $ref(router.options.routes[0].children)

const silder = $ref([])

routes[0].children.forEach(e=>silder.push(e))

function open(v:any,m:any){

  if(m == 'p'){
    silder.length = 0
    v.children.forEach((e: any)=>silder.push(e))
    router.push(v)
  }
  router.push(v)
}

</script>

<style scoped>
.top{
  height: 100px;
  background-color: pink;
}
.left{
  width: 200px;
  height: calc(100vh - 100px);
  background-color: lemonchiffon;
  float: left;
}
.right{
  width: calc(100% - 200px);
  height: calc(100vh - 100px);
  background-color: gray;
  float: left;
}
button{
  margin-left: 5px;
  display: block;
  text-decoration: none;
  width: 102px;
  height: 42px;
  background-color: #5cb85c;
  text-align: center;
  line-height: 42px;
  color: white;
  border-radius: 2px;
  font-size: 12px;
  border-width: 1px;
  border-style: solid;
  border-color: #5cb85c;
  float: left;
}
button:hover{
  display: block;
  text-decoration: none;
  width: 100px;
  height: 40px;
  background-color: #7ad67a;
  text-align: center;
  line-height: 40px;
  color: white;
  border-radius: 2px;
  font-size: 12px;

}
</style>